/*
 * @Author: your name
 * @Date: 2020-10-15 08:34:36
 * @LastEditTime: 2020-11-06 13:41:01
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \sende_nuxt\plugins\i18n.js
 */
import Vue from 'vue';
import VueI18n from 'vue-i18n'
Vue.use(VueI18n);

export default ({ app, store }) => {
  const data = {};
  const Locale = store.state.content.locales;
  for (let i = 0; i < Locale.length; i++) {
    data[Locale[i]] = require(`~/locales/${Locale[i]}.json`)
  }

  app.i18n = new VueI18n({
    locale: store.state.content.locale,
    fallbackLocale: 'en',
    messages: data,
    silentTranslationWarn: true
    // {
    //   'en': require('~/locales/en.json'),
    //   'zh': require('~/locales/zh.json')
    // }
  });
  // app.i18n.path = (link) => {
  //   if (app.i18n.locale === app.i18n.fallbackLocale) {
  //     return `/${link}`;
  //   }
  //   return `/${app.i18n.locale}/${link}`;
  // }
}
